package com.iot.menu.controller;

import com.iot.commonutils.utils.Result;
import com.iot.menu.entity.Menu;
import com.iot.menu.service.MenuService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 菜单管理
 */
@RestController
@RequestMapping("/sys")
public class MenuController {
    @Autowired
    private MenuService menuService;

    /**
     * 展示菜单列表
     *
     * @return
     */
    @GetMapping("/showMenuList")
    @ApiOperation("获取所有菜单")
    public Result getAllMenus() {
        return menuService.getAllMenus();
    }

    /**
     * 添加菜单
     * 需要添加类型,菜单名称,所属菜单,排序号,状态
     *
     * @return
     */
    @PostMapping("/addMenu")
    @ApiOperation("添加菜单")
    public Result addMenus(@RequestBody Menu menu) {
        return menuService.addMenus(menu);
    }

    @PostMapping("/updateMenu")
    @ApiOperation("更新菜单")
    public Result updateMenu(@RequestBody Menu menu) {
        return menuService.updateMenu(menu);
    }

    @DeleteMapping("/deleteMenu/{id}")
    @ApiOperation("/删除菜单")
    public Result deleteMenu(@PathVariable("id") String id){
        return menuService.deleteMenu(id);
    }

}
